﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KPIS.GERP.GHRMS.MODEL;
using System.Configuration;
using System.Data;
using KPIS.DBM;

namespace KPIS.GERP.GHRMS.DAL
{
    public class TR_CompetencyTypesDAL
    {
        DBManager dbManager = new DBManager(SystemInfo._DataProvider, ConfigurationSettings.AppSettings["ConnectionString"].ToString());
        ConvertNullable cn = new ConvertNullable();

        public IList<TR_CompetencyTypesInfo>GetFill()     
        {
            //เช็คว่า Data Table มีข้อมูลหรือไม่
            DataRowCollection drc = null;
            IList<TR_CompetencyTypesInfo> infoList = new List<TR_CompetencyTypesInfo>();
            try
            {
                dbManager.Open();
                //dbManager.CreateParameters(5);
                //dbManager.AddParameters(0, "@training_status_descr", "'" + infoparam.training_status_descr + "'");
                //dbManager.AddParameters(1, "@date_training", infoparam.date_training);
                //dbManager.AddParameters(2, "@training_cur_descr", infoparam.training_cur_descr);
                //dbManager.AddParameters(3, "@training_place", infoparam.training_place);
                //dbManager.AddParameters(4, "@training_create", infoparam.training_create);


                string strSQL = "SELECT ct.request_seq, ct.training_cur_descr"
                                + " FROM hrm_training_request ct";


                drc = dbManager.ExecuteDataSet(CommandType.Text, strSQL).Tables[0].Rows;

                if (drc.Count > 0)
                {
                    int i = 0;

                    while (i < drc.Count)
                    {
                        TR_CompetencyTypesInfo info = new TR_CompetencyTypesInfo();
                        info.competency_type_seq = Convert.ToInt32(drc[i]["request_seq"]);//1
                        info.competency_type_descr = drc[i]["training_cur_descr"].ToString();//2
                       
                        infoList.Add(info);

                        i++;
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                dbManager.Dispose(); //สั้งเคลียร์ Connections ของ Method
            }
            return infoList;
        }
    }
}
